home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Digital Information Mana…ntial Guide to Multimedia
/
Digital Information Management - An Essential Guide to Multimedia.iso
/
Portable
/
PortableOpenOfficeCode
/
PortableOpenOffice.nsi
< prev
next >
Wrap
Text File
|
2006-05-16
|
10KB
|
343 lines
;Copyright (C) 2004-2005 John T. Haller
;Additional Ideas from tracon and mai9
;Website: http://portableapps.com/portableopenoffice
;This software is OSI Certified Open Source Software.
;OSI Certified is a certification mark of the Open Source Initiative.
;This program is free software; you can redistribute it and/or
;modify it under the terms of the GNU General Public License
;as published by the Free Software Foundation; either version 2
;of the License, or (at your option) any later version.
;This program is distributed in the hope that it will be useful,
;but WITHOUT ANY WARRANTY; without even the implied warranty of
;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;GNU General Public License for more details.
;You should have received a copy of the GNU General Public License
;along with this program; if not, write to the Free Software
;Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
!define NAME "PortableOpenOffice"
!define FRIENDLYNAME "Portable OpenOffice.org"
!define APP "OpenOffice"
!define VER "1.1.3.0"
!define WEBSITE "portableapps.com/portableopenoffice"
!define DEFAULTEXE "soffice.exe"
!define DEFAULTAPPDIR "openoffice\program"
!define DEFAULTSETTINGSDIR "settings"
!define DEFAULTPARAMETERS ""
!include LogicLib.nsh
;=== Program Details
Name "${NAME}"
OutFile "${NAME}.exe"
Caption "${FRIENDLYNAME} - the complete office suite that's completely portable"
VIProductVersion "${VER}.0"
VIAddVersionKey FileDescription "${FRIENDLYNAME}"
VIAddVersionKey LegalCopyright "GPL"
VIAddVersionKey Comments "Allows ${APP} to be run from a removable drive. For additional details, visit ${WEBSITE}"
VIAddVersionKey CompanyName "by John T. Haller et al"
VIAddVersionKey OriginalFilename "${NAME}.exe"
VIAddVersionKey FileVersion "${VER}"
;=== Runtime Switches
CRCCheck On
WindowIcon Off
SilentInstall Silent
AutoCloseWindow True
;=== Program Icon
Icon "${APP}.ico"
Var PROGRAMDIRECTORY
Var SETTINGSDIRECTORY
Var SETTINGSDIRECTORYWITHOUTSPACES
Var SETTINGSDIRECTORYBOOTSTRAP
Var ADDITIONALPARAMETERS
Var EXECSTRING
Var WAITFORPROGRAM
Var PROGRAMEXECUTABLE
Var INIPATH
Var DISABLESPLASHSCREEN
!define StrRep "!insertmacro StrRep"
!macro StrRep ResultVar String SubString RepString
Push "${String}"
Push "${SubString}"
Push "${RepString}"
Call StrRep
Pop "${ResultVar}"
!macroend
Function StrRep
/*After this point:
------------------------------------------
$R0 = RepString (input)
$R1 = SubString (input)
$R2 = String (input)
$R3 = RepStrLen (temp)
$R4 = SubStrLen (temp)
$R5 = StrLen (temp)
$R6 = StartCharPos (temp)
$R7 = TempStrL (temp)
$R8 = TempStrR (temp)*/
;Get input from user
Exch $R0
Exch
Exch $R1
Exch
Exch 2
Exch $R2
Push $R3
Push $R4
Push $R5
Push $R6
Push $R7
Push $R8
;Return "String" if "SubString" is ""
${IfThen} $R1 == "" ${|} Goto Done ${|}
;Get "RepString", "String" and "SubString" length
StrLen $R3 $R0
StrLen $R4 $R1
StrLen $R5 $R2
;Start "StartCharPos" counter
StrCpy $R6 0
;Loop until "SubString" is found or "String" reaches its end
${Do}
;Remove everything before and after the searched part ("TempStrL")
StrCpy $R7 $R2 $R4 $R6
;Compare "TempStrL" with "SubString"
${If} $R7 == $R1
;Split "String" to replace the string wanted
StrCpy $R7 $R2 $R6 ;TempStrL
;Calc: "StartCharPos" + "SubStrLen" = EndCharPos
IntOp $R8 $R6 + $R4
StrCpy $R8 $R2 "" $R8 ;TempStrR
;Insert the new string between the two separated parts of "String"
StrCpy $R2 $R7$R0$R8
;Now calculate the new "StrLen" and "StartCharPos"
StrLen $R5 $R2
IntOp $R6 $R6 + $R3
${Continue}
${EndIf}
;If not "SubString", this could be "String" end
${IfThen} $R6 >= $R5 ${|} ${ExitDo} ${|}
;If not, continue the loop
IntOp $R6 $R6 + 1
${Loop}
Done:
;Return output to user
StrCpy $R0 $R2
/*After this point:
------------------------------------------
$R0 = ResultVar (output)*/
Pop $R8
Pop $R7
Pop $R6
Pop $R5
Pop $R4
Pop $R3
Pop $R2
Pop $R1
Exch $R0
FunctionEnd
Section "Main"
;=== Find the INI file, if there is one
IfFileExists "$EXEDIR\${NAME}.ini" "" CheckSubINI
StrCpy "$INIPATH" "$EXEDIR\"
Goto ReadINI
CheckSubINI:
IfFileExists "$EXEDIR\${NAME}\${NAME}.ini" "" CheckSubSubINI
StrCpy "$INIPATH" "$EXEDIR\${NAME}\"
Goto ReadINI
CheckSubSubINI:
IfFileExists "$EXEDIR\PortableApps\${NAME}\${NAME}.ini" "" CheckPortableAppsINI
StrCpy "$INIPATH" "$EXEDIR\PortableApps\${NAME}\"
Goto ReadINI
CheckPortableAppsINI:
IfFileExists "$EXEDIR\Data\${NAME}\${NAME}.ini" "" NoINI
StrCpy "$INIPATH" "$EXEDIR\Data\${NAME}\"
Goto ReadINI
ReadINI:
;=== Read the parameters from the INI file
ReadINIStr $0 "$INIPATH\${NAME}.ini" "${NAME}" "${APP}Directory"
StrCpy "$PROGRAMDIRECTORY" "$EXEDIR\$0"
ReadINIStr $0 "$INIPATH\${NAME}.ini" "${NAME}" "SettingsDirectory"
StrCpy "$SETTINGSDIRECTORY" "$0"
;=== Check that the above required parameters are present
IfErrors NoINI
ReadINIStr $0 "$INIPATH\${NAME}.ini" "${NAME}" "AdditionalParameters"
StrCpy "$ADDITIONALPARAMETERS" $0
ReadINIStr $0 "$INIPATH\${NAME}.ini" "${NAME}" "WaitFor${APP}"
StrCpy "$WAITFORPROGRAM" $0
ReadINIStr $0 "$INIPATH\${NAME}.ini" "${NAME}" "${APP}Executable"
StrCpy "$PROGRAMEXECUTABLE" $0
ReadINIStr $0 "$INIPATH\${NAME}.ini" "${NAME}" "DisableSplashScreen"
StrCpy "$DISABLESPLASHSCREEN" $0
;=== Any missing unrequired INI entries will be an empty string, ignore associated errors
ClearErrors
;=== Correct PROGRAMEXECUTABLE if blank
StrCmp $PROGRAMEXECUTABLE "" "" EndINI
StrCpy "$PROGRAMEXECUTABLE" "${DEFAULTEXE}"
Goto EndINI
NoINI:
;=== No INI file, so we'll use the defaults
StrCpy "$ADDITIONALPARAMETERS" ""
StrCpy "$WAITFORPROGRAM" "false"
StrCpy "$PROGRAMEXECUTABLE" "${DEFAULTEXE}"
StrCpy "$DISABLESPLASHSCREEN" "false"
IfFileExists "$EXEDIR\${DEFAULTAPPDIR}\${DEFAULTEXE}" "" CheckPortableProgramDIR
StrCpy "$PROGRAMDIRECTORY" "$EXEDIR\${DEFAULTAPPDIR}"
StrCpy "$SETTINGSDIRECTORY" "${DEFAULTSETTINGSDIR}"
GoTo EndINI
CheckPortableProgramDIR:
IfFileExists "$EXEDIR\${NAME}\${DEFAULTAPPDIR}\${DEFAULTEXE}" "" CheckPortableAppsDIR
StrCpy "$PROGRAMDIRECTORY" "$EXEDIR\${NAME}\${DEFAULTAPPDIR}"
StrCpy "$SETTINGSDIRECTORY" "${NAME}\${DEFAULTSETTINGSDIR}"
GoTo EndINI
CheckPortableAppsDIR:
IfFileExists "$EXEDIR\PortableApps\${NAME}\${DEFAULTAPPDIR}\${DEFAULTEXE}" "" CheckPortableAppsSplitDIR
StrCpy "$PROGRAMDIRECTORY" "$EXEDIR\PortableApps\${NAME}\${DEFAULTAPPDIR}"
StrCpy "$SETTINGSDIRECTORY" "PortableApps\${NAME}\${DEFAULTSETTINGSDIR}"
GoTo EndINI
CheckPortableAppsSplitDIR:
IfFileExists "$EXEDIR\Apps\${NAME}\${DEFAULTAPPDIR}\${DEFAULTEXE}" "" NoProgramEXE
StrCpy "$PROGRAMDIRECTORY" "$EXEDIR\Apps\${NAME}\${DEFAULTAPPDIR}"
StrCpy "$SETTINGSDIRECTORY" "Data\${NAME}\${DEFAULTSETTINGSDIR}"
EndINI:
IfFileExists "$PROGRAMDIRECTORY\$PROGRAMEXECUTABLE" FoundProgramEXE
NoProgramEXE:
;=== Program executable not where expected
MessageBox MB_OK|MB_ICONEXCLAMATION `$PROGRAMEXECUTABLE was not found. Please check your configuration`
Abort
FoundProgramEXE:
FindProcDLL::FindProc "soffice.bin"
Pop $R0
StrCmp $R0 "1" "" ShowSplashScreen
IfFileExists "$SETTINGSDIRECTORY\.lock" SkipSplashScreen
ShowSplashScreen:
StrCmp $DISABLESPLASHSCREEN "true" SkipSplashScreen
InitPluginsDir
File /oname=$PLUGINSDIR\splash.jpg "${NAME}.jpg"
newadvsplash::show /NOUNLOAD 3000 200 200 -1 /L $PLUGINSDIR\splash.jpg
SkipSplashScreen:
;=== Get any passed parameters
Call GetParameters
Pop $0
StrCmp "'$0'" "''" "" LaunchProgramParameters
;=== No parameters
StrCpy $EXECSTRING `"$PROGRAMDIRECTORY\$PROGRAMEXECUTABLE"`
Goto AdditionalParameters
LaunchProgramParameters:
StrCpy $EXECSTRING `"$PROGRAMDIRECTORY\$PROGRAMEXECUTABLE" $0`
AdditionalParameters:
StrCpy $EXECSTRING `$EXECSTRING${DEFAULTPARAMETERS}`
StrCmp $ADDITIONALPARAMETERS "" SetSettingsPath
;=== Additional Parameters
StrCpy $EXECSTRING `$EXECSTRING $ADDITIONALPARAMETERS`
SetSettingsPath:
;=== Set the settngs directory if we have a path
IfFileExists `$PROGRAMDIRECTORY\bootstrap.ini` "" NoBootStrap
${StrRep} $SETTINGSDIRECTORYWITHOUTSPACES "$EXEDIR\$SETTINGSDIRECTORY" " " "%20"
${StrRep} $SETTINGSDIRECTORYBOOTSTRAP $SETTINGSDIRECTORYWITHOUTSPACES "\" "/"
;MessageBox MB_OK|MB_ICONINFORMATION `file:///$SETTINGSDIRECTORYBOOTSTRAP`
WriteINIStr `$PROGRAMDIRECTORY\bootstrap.ini` "Bootstrap" "UserInstallation" "file:///$SETTINGSDIRECTORYBOOTSTRAP"
Goto LaunchNow
NoBootStrap:
MessageBox MB_OK|MB_ICONEXCLAMATION `$PROGRAMDIRECTORY\bootstrap.ini was not found. Please check your configuration`
Abort
LaunchNow:
StrCmp $WAITFORPROGRAM "true" LaunchAndWait LaunchAndClose
LaunchAndWait:
ExecWait $EXECSTRING
GoTo TheEnd
LaunchAndClose:
Exec $EXECSTRING
TheEnd:
Sleep 4000 ;=== Ensure the splash is closed
SectionEnd
Function "GetParameters"
Push $R0
Push $R1
Push $R2
StrCpy $R0 $CMDLINE 1
StrCpy $R1 '"'
StrCpy $R2 1
StrCmp $R0 '"' loop
StrCpy $R1 ' ' ; we're scanning for a space instead of a quote
loop:
StrCpy $R0 $CMDLINE 1 $R2
StrCmp $R0 $R1 loop2
StrCmp $R0 "\" "" "nofile"
IntOp $2 $R2 + 1
nofile:
;MessageBox MB_OK "r0: $R0"
StrCmp $R0 "" loop2
IntOp $R2 $R2 + 1
Goto loop
loop2:
IntOp $R0 $R2 - $2
IntOp $R0 $R0 - 4
;MessageBox MB_OK "$R2 - $2 = $R0"
StrCpy $R7 $CMDLINE $R0 $2 ; we save the filename
;MessageBox MB_OK "$2"
loop2b:
IntOp $R2 $R2 + 1
StrCpy $R0 $CMDLINE 1 $R2
;MessageBox MB_OK "rr0: $R0"
StrCmp $R0 " " loop2b
StrCpy $R0 $CMDLINE "" $R2
Pop $R2
Pop $R1
Exch $R0
FunctionEnd